<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>使一个图像中调色板版本的颜色与真彩色版本更能匹配</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.imagecolormatch" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">imagecolormatch</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">imagecolormatch</span> &mdash; <span class="dc-title">使一个图像中调色板版本的颜色与真彩色版本更能匹配</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.imagecolormatch-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>imagecolormatch</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$image1</code></span>
   , <span class="methodparam"><span class="type">resource</span> <code class="parameter">$image2</code></span>
   ) : <span class="type">bool</span></div>

  <p class="para rdfs-comment">
   使一个图像中调色板版本的颜色与真彩色版本更能匹配。
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.imagecolormatch-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">image1</code></dt>

     <dd>

      <p class="para">
       真彩色图像连接资源。
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">image2</code></dt>

     <dd>

      <p class="para">
       必须是调色板图像，而且和  <code class="parameter">image1</code> 的大小必须相同。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.imagecolormatch-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>TRUE</code></strong>， 或者在失败时返回 <strong><code>FALSE</code></strong>。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.imagecolormatch-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-3668">
   <p><strong>Example #1 <span class="function"><strong>imagecolormatch()</strong></span> 例子</strong></p>
   <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Setup&nbsp;the&nbsp;true&nbsp;color&nbsp;and&nbsp;palette&nbsp;images<br /></span><span style="color: #0000BB">$im1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatefrompng</span><span style="color: #007700">(</span><span style="color: #DD0000">'./gdlogo.png'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$im2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreate</span><span style="color: #007700">(</span><span style="color: #0000BB">imagesx</span><span style="color: #007700">(</span><span style="color: #0000BB">$im1</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">imagesy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im1</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">//&nbsp;Add&nbsp;some&nbsp;colors&nbsp;to&nbsp;$im2<br /></span><span style="color: #0000BB">$colors&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;Array();<br /></span><span style="color: #0000BB">$colors</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">255</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">36</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">74</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$colors</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">40</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">240</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$colors</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">82</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">100</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">255</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$colors</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">imagecolorallocate</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">84</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">63</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">44</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Match&nbsp;these&nbsp;colors&nbsp;with&nbsp;the&nbsp;true&nbsp;color&nbsp;image<br /></span><span style="color: #0000BB">imagecolormatch</span><span style="color: #007700">(</span><span style="color: #0000BB">$im1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$im2</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Free&nbsp;from&nbsp;memory<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagedestroy</span><span style="color: #007700">(</span><span style="color: #0000BB">$im2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
   </div>

  </div>
 </div>

 <div class="refsect1 notes" id="refsect1-function.imagecolormatch-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数仅在与 GD 库捆绑编译的 PHP 版本中可用。</span></p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数需要 GD 2.0.1 或更高版本(推荐 2.0.28 及更高版本)。</span></p></blockquote>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.imagecolormatch-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="imagecreatetruecolor.html" class="function" rel="rdfs-seeAlso">imagecreatetruecolor()</a> - 新建一个真彩色图像</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>